package springboot.demo.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/prop")
@ResponseBody
@Controller
public class PropertiesController {
    @Value("${my.key1}")
    private Integer mykey1;

    @Value("${my.key2}")
    private boolean mykey2;

    @RequestMapping("/read")
    public String readvalue(){
        return ("读取配置文件my.key" + mykey1);
    }

    @PostConstruct
    public void init(){
        System.out.println("my.key:" + mykey1);
        System.out.println("my.key2:" + mykey2);
    }

}
